// ColorRamp.h
//
#ifndef COLORRAMP_H
#define COLORRAMP_H

#include "OpenGL.h"
#include "Texture.h"
//#include "Program.h"

#include <map>

namespace OpenGL {

class Color;

class ColorRamp
{
//public:
//	class Color
//	{
//	public:
//		unsigned char r,g,b,a;
//		Color() : r(64),g(64),b(64),a(255){}
//		Color(unsigned char R, unsigned char G, unsigned char B, unsigned char A) : r(R),g(G),b(B),a(A) {}
//		Color operator = (const Color &c)
//		{
//			r = c.r;
//			g = c.g;
//			b = c.b;
//			a = c.a;
//			return *this;
//		}
//	};

private:
	//static Program shader;
	unsigned int unit;
	Texture1D ramp;
	std::map<double, Color> entries;
	double maxValue,minValue;
	
public:
	//static bool initShader();
	ColorRamp();
	virtual ~ColorRamp();

	void build(int resolution = 1024);
	void destroy();

	void bind(unsigned int textureUnit=0);
	void unBind();

	//void setCurrentMinMax(float minHeigth,float maxHeight);

	void addColor(double position,const Color &color, bool autoRebuild = false);
	
	double getMin() {return minValue;}
	double getMax() {return maxValue;}
};

}

#endif